Activities

Row

Type of workouts

Length of workouts

Row

Distance of workouts per type

Some other plot

Year-to-date statistics

Column

Statistics

Column

Yearly goal

Montly distance

---
title: "Strava-flex"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(rStrava)
library(jsonlite)
library(ggplot2)
library(plotly)
library(highcharter)

strava_keys = fromJSON('keys.json')$strava
strava_goals = fromJSON('keys.json')$goals
stoken <- httr::config(token = strava_oauth(strava_keys$app_name,
                                            strava_keys$client_id,
                                            strava_keys$client_secret))

activities <- get_activity_list(stoken)
athlete <- get_athlete(stoken)
df <- compile_activities(activities)
df$row <- seq.int(nrow(df))
```

Sidebar {.sidebar}
=======================================================================
### Athlete Information
```{r}
athlete$firstname
athlete$lastname
athlete$city
athlete$country
```

Activities {data-icon="fa-signal"}
=======================================================================

Row
-----------------------------------------------------------------------
### Type of workouts
```{r}
p <- ggplot(df, aes(type)) +
  geom_bar()
ggplotly(p)
```

### Length of workouts
```{r}
p <- ggplot(df, aes(x=distance, color=type)) +
  geom_histogram(fill="white", alpha=0.5, position="identity")
ggplotly(p)
```

Row
-----------------------------------------------------------------------
### Distance of workouts per type
```{r}
hchart(df$type, name="Number of workouts")
```

### Some other plot
```{r}
hchart(df$distance, name="Number of workouts")
```

Year-to-date statistics {data-icon="fa-chart-bar"}
=======================================================================
Column
-----------------------------------------------------------------------
### Statistics
```{r}
```

Column
-----------------------------------------------------------------------
### Yearly goal
```{r}
gauge(91, min = 0, max = strava_goals$yearly, symbol = '%', gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
```

### Montly distance